<template>
  <div class="order-list page-container">
    <div class="page-header">
      <div class="header-content">
        <h1 class="page-title">订单列表</h1>
        <p class="page-subtitle">管理系统订单信息，查看订单状态</p>
      </div>
    </div>

    <div class="content-card">
      <div class="search-section">
        <el-input
          v-model="searchOrderNo"
          placeholder="订单编号"
          class="search-input"
          clearable
        >
          <template #prefix>
            <svg class="search-icon" viewBox="0 0 24 24" fill="currentColor">
              <path
                d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
              />
            </svg>
          </template>
        </el-input>
        <el-input
          v-model="searchUserId"
          placeholder="用户ID"
          class="search-input"
          clearable
        />
        <el-input
          v-model="searchReceiverName"
          placeholder="收货人"
          class="search-input"
          clearable
        />
        <el-input
          v-model="searchReceiverPhone"
          placeholder="收货人手机号"
          class="search-input"
          clearable
        />
        <el-select
          v-model="searchStatus"
          placeholder="选择订单状态"
          clearable
          multiple
          class="status-select"
        >
          <el-option label="待支付" :value="'pending_payment'" />
          <el-option label="待发货" :value="'pending_shipment'" />
          <el-option label="待收货/使用" :value="'pending_receipt'" />
          <el-option label="售后" :value="'after_sales'" />
          <el-option label="已完成" :value="'completed'" />
          <el-option label="已关闭" :value="'closed'" />
        </el-select>
        <el-select
          v-model="searchOrderType"
          placeholder="订单类型"
          clearable
          class="type-select"
        >
          <el-option label="普通订单" :value="1" />
          <el-option label="满减订单" :value="2" />
          <el-option label="折扣订单" :value="3" />
          <el-option label="特价订单" :value="4" />
        </el-select>
        <el-date-picker
          v-model="dateRange"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          value-format="YYYY-MM-DD HH:mm:ss"
          class="date-picker"
        />
        <!-- 添加导出按钮 -->
        <el-button
          type="success"
          @click="handleExportPicking"
          :loading="exportLoading"
          class="export-btn"
        >
          <template #icon>
            <el-icon><Download /></el-icon>
          </template>
          导出配货单
        </el-button>
        <el-button type="primary" @click="handleSearch">搜索</el-button>
        <el-button @click="resetSearch">重置</el-button>
      </div>

      <el-table
        :data="orders"
        style="width: 100%"
        class="order-table"
        v-loading="loading"
      >
        <el-table-column type="index" label="序号" width="80" align="center" />
        <el-table-column
          prop="orderNo"
          label="订单号"
          width="200"
          show-overflow-tooltip
        />
        <el-table-column
          prop="userId"
          label="用户ID"
          width="150"
          show-overflow-tooltip
        />

        <!-- 订单类型 -->
        <el-table-column
          prop="orderType"
          label="订单类型"
          width="100"
          align="center"
        >
          <template #default="{ row }">
            <el-tag :type="getOrderTypeTagType(row.orderType)" size="small">
              {{ getOrderTypeText(row.orderType) }}
            </el-tag>
          </template>
        </el-table-column>

        <!-- 订单状态 -->
        <el-table-column
          prop="orderStatus"
          label="订单状态"
          width="120"
          align="center"
        >
          <template #default="{ row }">
            <el-tag :type="getStatusType(row.orderStatus)" size="small">
              {{ getStatusText(row.orderStatus) }}
            </el-tag>
          </template>
        </el-table-column>

        <!-- 订单总金额 -->
        <el-table-column
          prop="totalAmount"
          label="订单总金额"
          width="120"
          align="right"
        >
          <template #default="{ row }">
            <div class="amount-cell total-amount">
              <div class="amount-label">总金额</div>
              <div class="amount-value">
                {{ formatCurrency(row.totalAmount) }}
              </div>
            </div>
          </template>
        </el-table-column>

        <!-- 促销优惠 -->
        <el-table-column
          prop="discountAmount"
          label="促销优惠"
          width="100"
          align="right"
        >
          <template #default="{ row }">
            <div
              v-if="row.discountAmount > 0"
              class="amount-cell discount-amount"
            >
              <div class="amount-label">促销优惠</div>
              <div class="amount-value discount-value">
                -{{ formatCurrency(row.discountAmount) }}
              </div>
            </div>
            <div v-else class="amount-cell no-amount">
              <div class="amount-label">促销优惠</div>
              <div class="amount-value">-</div>
            </div>
          </template>
        </el-table-column>

        <!-- 积分抵扣 -->
        <el-table-column
          prop="pointAmount"
          label="积分抵扣"
          width="100"
          align="right"
        >
          <template #default="{ row }">
            <div v-if="row.pointAmount > 0" class="amount-cell point-amount">
              <div class="amount-label">积分抵扣</div>
              <div class="amount-value point-value">
                -{{ formatCurrency(row.pointAmount) }}
              </div>
            </div>
            <div v-else class="amount-cell no-amount">
              <div class="amount-label">积分抵扣</div>
              <div class="amount-value">-</div>
            </div>
          </template>
        </el-table-column>

        <!-- 运费 -->
        <el-table-column
          prop="freightAmount"
          label="运费"
          width="80"
          align="right"
        >
          <template #default="{ row }">
            <div class="amount-cell freight-amount">
              <div class="amount-label">运费</div>
              <div class="amount-value freight-value">
                {{ formatCurrency(row.freightAmount) }}
              </div>
            </div>
          </template>
        </el-table-column>

        <!-- 订单实付总金额 -->
        <el-table-column
          prop="paymentAmount"
          label="订单实付总金额"
          width="130"
          align="right"
        >
          <template #default="{ row }">
            <div class="amount-cell payment-amount">
              <div class="amount-label">需付</div>
              <div class="amount-value payment-value">
                {{ formatCurrency(row.paymentAmount) }}
              </div>
            </div>
          </template>
        </el-table-column>

        <!-- 已付金额 -->
        <el-table-column
          prop="freightAmount"
          label="已付款金额"
          width="120"
          align="right"
        >
          <template #default="{ row }">
            <div class="amount-cell paid-amount">
              <div class="amount-label">已付</div>
              <div class="amount-value paid-value">
                {{ formatCurrency(row.paidAmount || 0) }}
              </div>
            </div>
          </template>
        </el-table-column>

        <!-- 已退款金额 -->
        <el-table-column
          prop="freightAmount"
          label="已退款金额"
          width="120"
          align="right"
        >
          <template #default="{ row }">
            <div class="amount-cell refund-amount">
              <div class="amount-label">已退</div>
              <div class="amount-value refund-value">
                -{{ formatCurrency(row.refundedAmount || 0) }}
              </div>
            </div>
          </template>
        </el-table-column>

        <!-- 下单时间 -->
        <el-table-column
          prop="createdTime"
          label="下单时间"
          width="160"
          show-overflow-tooltip
        />

        <!-- 支付时间 -->
        <el-table-column
          prop="paymentTime"
          label="支付时间"
          width="160"
          show-overflow-tooltip
        >
          <template #default="{ row }">
            <span v-if="row.paymentTime">{{ row.paymentTime }}</span>
            <span v-else class="no-payment">-</span>
          </template>
        </el-table-column>

        <!-- 操作列 -->
        <el-table-column label="操作" width="130" fixed="right">
          <template #default="{ row }">
            <div class="action-buttons">
              <el-button
                size="small"
                type="info"
                @click="viewOrderDetail(row)"
                class="action-btn"
              >
                详情
              </el-button>
              <el-button
                size="small"
                type="warning"
                @click="cancelOrder(row)"
                class="action-btn"
                :disabled="row.orderStatus !== 0"
                v-if="row.orderStatus === 0"
              >
                取消
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <div class="pagination-wrapper">
        <el-pagination
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          :page-sizes="[10, 20, 50, 100]"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { ElMessage, ElMessageBox } from "element-plus";
import { Download } from "@element-plus/icons-vue";
import { postWithAuth } from "@/utils/request";
import { useOutboundCsvExport } from "@/composables/useOutboundCsvExport";

interface OrderInfoVO {
  id: string;
  orderNo: string;
  userId: string;
  orderStatus: number;
  totalAmount: number | null;
  paymentAmount: number | null;
  discountAmount: number | null;
  freightAmount: number | null;
  refundAmount: number | null;
  pointAmount: number | null;
  paymentType: number | null; // 1支付宝 2微信
  paymentTime: string | null;
  paymentSerialNo: string | null;
  deliveryCompany: string | null;
  deliveryNo: string | null;
  deliveryTime: string | null;
  receiveTime: string | null;
  source: number | null;
  orderType: number | null; // 1-普通，2-满减，3-折扣，4-特价，5-拼团
  promotionId: string | null;
  remark: string | null;
  createdTime: string;
  modifiedTime: string | null;
  itemVOS: any[] | null;
}

const router = useRouter();
const loading = ref(false);

// 使用导出配货单功能
const { exportLoading, handleExportPicking } = useOutboundCsvExport();

// 搜索条件
const searchOrderNo = ref("");
const searchUserId = ref("");
const searchReceiverName = ref("");
const searchReceiverPhone = ref("");
const searchStatus = ref<string | string[] | null>(null); // 支持单选或多选
const searchOrderType = ref<number | null>(null);
const dateRange = ref<[string, string] | []>([]);

// 分页
const currentPage = ref(1);
const pageSize = ref(10);
const total = ref(0);

const orders = ref<OrderInfoVO[]>([]);

// 获取订单类型标签类型
const getOrderTypeTagType = (type: number | null): string => {
  if (!type) return "info";
  switch (type) {
    case 1:
      return "info"; // 普通
    case 2:
      return "success"; // 满减
    case 3:
      return "warning"; // 折扣
    case 4:
      return "danger"; // 特价
    case 5:
      return "primary"; // 拼团
    default:
      return "info";
  }
};

// 获取订单类型文本
const getOrderTypeText = (type: number | null): string => {
  if (!type) return "普通";
  switch (type) {
    case 1:
      return "普通";
    case 2:
      return "满减";
    case 3:
      return "折扣";
    case 4:
      return "特价";
    case 5:
      return "拼团";
    default:
      return "普通";
  }
};

// 获取合并后的订单状态
const getMergedStatus = (originalStatus: number): string => {
  switch (originalStatus) {
    case 0:
      return "pending_payment"; // 待支付
    case 1:
    case 10:
      return "pending_shipment"; // 待发货
    case 3:
      return "pending_receipt"; // 待收货/使用
    case 6:
    case 7:
    case 8:
      return "after_sales"; // 售后
    case 4:
    case 9:
      return "completed"; // 已完成
    case 2:
    case 5:
      return "closed"; // 已关闭
    default:
      return "unknown";
  }
};

// 获取合并后状态的标签类型
const getMergedStatusType = (mergedStatus: string): string => {
  switch (mergedStatus) {
    case "pending_payment":
      return "warning"; // 待支付
    case "pending_shipment":
      return "primary"; // 待发货
    case "pending_receipt":
      return "success"; // 待收货/使用
    case "after_sales":
      return "warning"; // 售后
    case "completed":
      return "success"; // 已完成
    case "closed":
      return "default"; // 已关闭
    default:
      return "info";
  }
};

// 获取合并后状态的文本
const getMergedStatusText = (mergedStatus: string): string => {
  switch (mergedStatus) {
    case "pending_payment":
      return "待支付";
    case "pending_shipment":
      return "待发货";
    case "pending_receipt":
      return "待收货/使用";
    case "after_sales":
      return "售后";
    case "completed":
      return "已完成";
    case "closed":
      return "已关闭";
    default:
      return "未知";
  }
};

// 获取原始状态的标签类型（保留用于兼容）
const getStatusType = (status: number): string => {
  const mergedStatus = getMergedStatus(status);
  return getMergedStatusType(mergedStatus);
};

// 获取原始状态的文本（保留用于兼容）
const getStatusText = (status: number): string => {
  const mergedStatus = getMergedStatus(status);
  return getMergedStatusText(mergedStatus);
};

// 格式化货币
const formatCurrency = (value: number | null | undefined): string => {
  if (value === null || value === undefined) return "-";
  const num = Number(value);
  if (Number.isNaN(num)) return "-";
  return `¥${num.toFixed(2)}`;
};

// 获取订单列表（支持多选状态）
const fetchOrders = async () => {
  loading.value = true;
  try {
    // 将合并后的状态转换为原始状态数组
    const getOriginalStatuses = (mergedStatus: string): number[] => {
      switch (mergedStatus) {
        case "pending_payment":
          return [0]; // 待支付
        case "pending_shipment":
          return [1, 10]; // 待发货
        case "pending_receipt":
          return [3]; // 待收货/使用
        case "after_sales":
          return [6, 7, 8]; // 售后
        case "completed":
          return [4, 9]; // 已完成
        case "closed":
          return [2, 5]; // 已关闭
        default:
          return [];
      }
    };

    // 处理多选状态
    let orderStatusArray: number[] = [];
    if (searchStatus.value && Array.isArray(searchStatus.value)) {
      // 多选情况
      orderStatusArray = searchStatus.value.flatMap((status) =>
        getOriginalStatuses(status)
      );
    } else if (searchStatus.value && typeof searchStatus.value === "string") {
      // 单选情况
      orderStatusArray = getOriginalStatuses(searchStatus.value);
    }

    const params: any = {
      orderNo: searchOrderNo.value || "",
      userId: searchUserId.value || "",
      receiverName: searchReceiverName.value || "",
      receiverPhone: searchReceiverPhone.value || "",
      orderStatus: orderStatusArray, // 始终为数组
      orderType: searchOrderType.value ?? "",
      pageIndex: currentPage.value,
      pageSize: pageSize.value,
      startTime:
        Array.isArray(dateRange.value) && dateRange.value.length === 2
          ? dateRange.value[0]
          : "",
      endTime:
        Array.isArray(dateRange.value) && dateRange.value.length === 2
          ? dateRange.value[1]
          : "",
    };

    const res = await postWithAuth("/internal/order/page", params);
    if (res.code === 0 && res.data) {
      orders.value = Array.isArray(res.data.list) ? res.data.list : [];
      total.value = Number(res.data.total || 0);
    } else {
      orders.value = [];
      total.value = 0;
      ElMessage.error(res.message || "获取订单列表失败");
    }
  } catch (error) {
    console.error("获取订单列表失败:", error);
    ElMessage.error("获取订单列表失败");
  } finally {
    loading.value = false;
  }
};

// 搜索
const handleSearch = () => {
  currentPage.value = 1;
  fetchOrders();
};

// 重置搜索
const resetSearch = () => {
  searchOrderNo.value = "";
  searchUserId.value = "";
  searchReceiverName.value = "";
  searchReceiverPhone.value = "";
  searchStatus.value = null;
  searchOrderType.value = null;
  dateRange.value = [];
  currentPage.value = 1;
  fetchOrders();
};

// 分页大小改变
const handleSizeChange = (val: number) => {
  pageSize.value = val;
  currentPage.value = 1;
  fetchOrders();
};

// 当前页改变
const handleCurrentChange = (val: number) => {
  currentPage.value = val;
  fetchOrders();
};

// 查看订单详情
const viewOrderDetail = (order: OrderInfoVO) => {
  router.push(`/order-detail/${order.id}`);
};

// 取消订单
const cancelOrder = async (row: OrderInfoVO) => {
  try {
    await ElMessageBox.confirm(
      `确定要取消订单"${row.orderNo}"吗？`,
      "确认取消",
      {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }
    );

    const response = await postWithAuth("/internal/order/cancel", {
      orderId: row.id,
    });

    if (response.code === 0) {
      ElMessage.success("订单取消成功");
      fetchOrders();
    } else {
      ElMessage.error(response.message || "取消订单失败");
    }
  } catch (error) {
    if (error !== "cancel") {
      console.error("取消订单失败:", error);
      ElMessage.error("取消订单失败");
    }
  }
};

// 组件挂载时获取订单列表
onMounted(() => {
  fetchOrders();
});
</script>

<style scoped>
.order-list {
  padding: 24px;
  background: #f5f7fa;
  min-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.header-content {
  flex: 1;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: #2d3748;
  margin: 0 0 8px 0;
}

.page-subtitle {
  color: #718096;
  margin: 0;
  font-size: 16px;
}

.content-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.search-section {
  padding: 20px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  width: 180px;
}

.status-select {
  width: 160px;
}

.type-select {
  width: 140px;
}

.date-picker {
  width: 280px;
}

.search-icon {
  width: 16px;
  height: 16px;
  color: #9ca3af;
}

.search-row {
  display: flex;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
}

.search-row:last-child {
  margin-bottom: 0;
}

.search-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.search-item-large {
  flex: 2;
}

.search-label {
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 6px;
  line-height: 1.4;
}

.search-input .el-input__wrapper {
  border-radius: 8px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.search-input .el-input__wrapper:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.search-input .el-input__wrapper.is-focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.status-select .el-select__wrapper,
.type-select .el-select__wrapper {
  border-radius: 8px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.status-select .el-select__wrapper:hover,
.type-select .el-select__wrapper:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.date-picker .el-input__wrapper {
  border-radius: 8px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.date-picker .el-input__wrapper:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.search-actions {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-left: 8px;
}

.search-btn,
.reset-btn {
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-btn {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border: none;
  box-shadow: 0 2px 4px 0 rgba(59, 130, 246, 0.3);
}

.search-btn:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  box-shadow: 0 4px 8px 0 rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.reset-btn {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #6b7280;
}

.reset-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  color: #374151;
  transform: translateY(-1px);
}

.btn-icon {
  font-size: 14px;
}

.search-icon {
  color: #9ca3af;
  font-size: 16px;
}

.order-table {
  margin-bottom: 24px;
}

/* 金额单元格基础样式 */
.amount-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 4px 0;
}

.amount-label {
  font-size: 11px;
  color: #8b949e;
  font-weight: 400;
  line-height: 1.2;
}

.amount-value {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

/* 订单总金额样式 */
.total-amount .amount-value {
  color: #24292f;
  font-weight: 600;
}

/* 促销优惠样式 */
.discount-amount .amount-value {
  color: #1a7f37;
  font-weight: 600;
}

.discount-value {
  background: linear-gradient(135deg, #1a7f37 0%, #2ea043 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 积分抵扣样式 */
.point-amount .amount-value {
  color: #d29922;
  font-weight: 600;
}

.point-value {
  background: linear-gradient(135deg, #d29922 0%, #f0b72f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 运费样式 */
.freight-amount .amount-value {
  color: #6f42c1;
  font-weight: 600;
}

.freight-value {
  background: linear-gradient(135deg, #6f42c1 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 商品实付金额样式 */
.payment-amount .amount-value {
  color: #0969da;
  font-weight: 700;
}

.payment-value {
  background: linear-gradient(135deg, #0969da 0%, #218bff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 无金额显示样式 */
.no-amount .amount-value {
  color: #8b949e;
  font-weight: 400;
}

.no-payment {
  color: #a0aec0;
  font-size: 13px;
}

/* 已付金额样式 */
.paid-amount .amount-value {
  color: #10b981;
  font-weight: 600;
}

.paid-value {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* 已退款金额样式 */
.refund-amount .amount-value {
  color: #ef4444;
  font-weight: 600;
}

.refund-value {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.action-btn {
  margin-right: 4px;
  margin-bottom: 4px;
  padding: 4px 8px;
  font-size: 11px;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}

.action-buttons .el-button {
  padding: 3px 6px;
  font-size: 13px;
  min-width: auto;
}

.pagination-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

/* 平板端适配 */
@media (max-width: 1024px) {
  .order-list {
    padding: 20px;
  }

  .page-header {
    padding: 20px;
  }

  .page-title {
    font-size: 24px;
  }

  .page-subtitle {
    font-size: 14px;
  }

  .content-card {
    padding: 20px;
  }

  .search-section {
    padding: 16px;
  }

  .search-row {
    flex-wrap: wrap;
    gap: 16px;
  }

  .search-item {
    flex: 1 1 calc(50% - 8px);
    min-width: 200px;
  }

  .search-item-large {
    flex: 1 1 100%;
  }

  .search-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    margin-left: 0;
    margin-top: 8px;
  }
}

/* 手机端适配 */
@media (max-width: 768px) {
  .order-list {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
    padding: 20px;
  }

  .page-title {
    font-size: 20px;
    margin-bottom: 6px;
  }

  .page-subtitle {
    font-size: 13px;
  }

  .content-card {
    padding: 16px;
    border-radius: 10px;
  }

  .search-section {
    padding: 16px;
  }

  .search-row {
    flex-direction: column;
    gap: 12px;
  }

  .search-item {
    flex: none;
    width: 100%;
  }

  .search-actions {
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
  }

  .search-btn,
  .reset-btn {
    width: 100%;
    justify-content: center;
  }

  .order-table {
    margin-bottom: 20px;
  }

  .amount-cell {
    padding: 2px 0;
  }

  .amount-label {
    font-size: 10px;
  }

  .amount-value {
    font-size: 13px;
  }

  .action-btn {
    margin-right: 4px;
    margin-bottom: 4px;
    padding: 4px 8px;
    font-size: 11px;
  }

  .pagination-wrapper {
    margin-top: 20px;
  }
}
</style>
